home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / EGAVGA.SWG / 0064_Using ALL the memory.pas < prev    next >
Pascal/Delphi Source File  |  1993-11-02  |  2KB  |  72 lines

  1. {
  2. JAMES SAITO
  3.  
  4. > I wonder if I can allocate With GetMem more than 64K, though. You see, I'm
  5. > interested in creating games With my own code, and the most important part
  6. > of games is Graphics. You don't want to play some dumb monochrome Text
  7. > adventure With a little man (@). :) Do you have any tips For outputting a
  8. > screen of information such as a part of a dungeon? I'd sorta like to keep
  9. > the Character centered like in Nintendo games.
  10.  
  11. Well.  if you want to make a 320x200x256 game, I know the right stuff.  if you
  12. would like to make the Character centered, and when you press
  13. up/down/left/right, the whole screen scrolls.  Here is an example on a playing
  14. field that is umm.  Let's say 1000x200 (200K).
  15. }
  16. Var
  17.   Field  : Array [0..199] of Pointer;  {The Field}
  18.   P      : Pointer;  {I'll tell you what happens With this}
  19.   Count,
  20.   Count2 : Integer;
  21.  
  22. begin
  23.   {Init The Graphics}
  24.   Asm
  25.     MOV AH,00H  {AH = 0}
  26.     MOV AL,13H  {AL = 13H,which is the Graphics mode 320x200x256}
  27.     INT 10H     {Call the Graphics bios services}
  28.   end;
  29.  
  30.   if Mem[$40:$49] <> $13 Then
  31.   begin
  32.     WriteLn('VGA Graphics Required For this game');
  33.     Halt(1);
  34.   end;
  35.  
  36.   For Count := 0 to 199 do
  37.   begin
  38.     getmem(field[count],1000);   {Find a chunk of memory For the field}
  39.     For count2 := 0 to 999 do
  40.       mem[seg(field[count]^) : ofs(field[count]^)] := random(256);
  41.       {Create a random field}
  42.   end;
  43.   getmem(p, 64000);
  44.   For Count2 := 0 to 679 do
  45.   begin
  46.     For count := 0 to 199 do
  47.       Move(mem[seg(field[count]^) : ofs(field[count]^) + Count2],
  48.            mem[seg(p^) : ofs(p^) + count * 320], 320);
  49.     {Now do put your player on, supposing it's a white block}
  50.     For count := 90 to 110 do
  51.       FillChar(mem[seg(p^) : ofs(p^) + count * 320 + 150], 20, 15);
  52.     move (p^, mem[$A000 : 0], 64000);
  53.     {Now copy that workspace into the video memory}
  54.   end;
  55.  
  56.   {Now time to close the Graphics}
  57.   Asm
  58.     MOV AH,$00;
  59.     MOV AL,$03;
  60.     INT 10H
  61.   end;
  62.  
  63.   {Free all blocks}
  64.   For Count := 0 to 199 do
  65.     freemem(field[count], 320);
  66.   freemem(p, 64000);
  67. end.
  68. {
  69.   Well.  That's it.  It actually took me 20 minutes to Type this whole thing
  70. right in the message base.  I guess there's a bit of errors.  - James Saito
  71. }
  72.